package com.kaifamiao.convert;

import java.time.*;
import java.util.Date;

public class ZonedDateTimeToDate {

    public static void main(String[] args) {

        LocalDateTime dt = LocalDateTime.now();

        // 父类型引用变量指向子类型对象
        ZoneId zone = ZoneOffset.ofHours( 8 );
        // LocalDateTime ====> ZonedDateTime
        ZonedDateTime zdt = dt.atZone( zone );
        System.out.println( zdt );

        // ZonedDateTime ====> Instant
        Instant instant = zdt.toInstant();

        // Instant ====> Date
        Date date = Date.from( instant );
        System.out.println( date );

    }

}
